package newsDB;

import java.util.List;

import newsEntity.Comments;

public class CommentsDao extends BaseDao {
	public static CommentsDao cd = new CommentsDao();

	public List<Comments> findComments(long cnid) {
		String sql = "SELECT ccontent,cdate,cip,cauthor FROM `comments` WHERE `cnid`=? GROUP BY `cdate` DESC";
		return find(sql, Comments.class, cnid);
	}

	public void addComments(String cauthor, String cip, String ccontent, Long cnid) {
		String sql = "INSERT INTO `comments`(`cnid`,`cauthor`,`cip`,`ccontent`) VALUES(?,?,?,?)";
		executeUpdate(sql, cnid, cauthor, cip, ccontent);
	}
}
